<script type="text/javascript" async="async">
$(document).ready(function(){
	$("#add").on("click",function(){
		window.location.href="${path}/role/add";
	});
	
	$("button[data-type='editor-button']").on("click",function(e){
		var id = $(this).attr("data-id");
		window.location.href="${path}/role/editor?roleId=" + id;
	});
	$("button[data-type='look-button']").on("click",function(){
		alert("look");
	});
	
	$("#delect").on("click",function(){
		var role = "";
		var checkbox=$("input[name='check']");
	    for(i=0;i<checkbox.length;i++){
	        if(checkbox[i].checked){
	        	role = role + checkbox[i].value + ",";
	        }
	    }
	    if(role == ""){
	    	alert("什么都没选中");
	    }else{
	    	$.post("${path}/role/delects",{roleIds:role},function(data){
				if(data.success){
					location.reload();
				}
			});
	    }
	})
	$("button[data-type='delect-button']").on("click",function(){
		var id = $(this).attr("data-id");
		$.post("${path}/role/delect",{roleId:id},function(data){
			if(data.success){
				location.reload();
			}
		});
	});
});
</script>
<div>
	<form id="roleForm" action="${path}/role/list" method="post">
		<input name="params">
		<button>查询</button>
	</form>
	<div>
		<button id="add">添加角色</button><button id="delect">删除角色</button>
		<h4>角色列表</h4>
		#foreach ($role in $list)
			<input type="checkbox" name="check" value="${role.id}" />
			$!{velocityCount}. ${role.name} -- ${role.grade} -- ${role.introduction} -- 
			#if(${role.status} == 0) <span>启用</span> #else <span>停用</span> #end 
			<button data-type='editor-button' data-id = "${role.id}">修改</button>
			<button data-type='look-button' data-id = "${role.id}">查看</button>
			<button data-type='delect-button' data-id = "${role.id}">删除</button><br/>
		#end 
	</div><br/>
</div>